<?php
include_once '!config.php';
use models\File as File;
$file = new File;
$smarty->assign('fieldId',$_POST['fieldId']);
switch ($_GET['action']) {
    case 'create'  :    if($_POST['action'] == 'uploadBrows'){ 
                            $item['fileTypes'] = File::getFileTypes();
                            $item['files'] = $file->read();
                            $templates[] = 'form/file/uploadDialog.tpl';
                        }
                        else if($_POST['action'] == 'fileAltEditForm'){
                           $item['fieldId'] = $_POST['fieldId'];
                           $item['file'] = $file->getFile($_POST['fileId'], $_POST['fieldId']);
                           $templates[] = 'form/file/alt.tpl';
                        }
                        break;

   

}

$smarty->assign('item', $item);
if($templates) foreach($templates as $template){
    $response['content'].=$smarty->fetch($template);
}
if($response['content']) $response['status'] = 'OK!';
echo json_encode($response);
?>
